// pages/message/message.js
var util = require("../../utils/util.js");
Page({
    //分享
    onShareAppMessage: function () { },
    /**
     * 页面的初始数据
     */
    data: {
        isshow: true,
        show_list: true,
        myMessage: []
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.getMyMessage();
        this.getMyNotice();
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },
    change() {
        this.setData({
            isshow: !this.data.isshow,
            show_list: !this.data.show_list
        })
    },
    //获取我的消息
    getMyMessage:function(){
        var that = this;
        var userInfo = JSON.parse(wx.getStorageSync("userInfo"));
        util.wxAjax("glMessage/getMessageAdmin","post",{
            adminid:userInfo.smAdmin.id
        },function(res){
            var data = res.data;
            if(data.result == 200 || data.result == "200"){
                if (!!data.data) {
                    that.setData({
                        myMessage: data.data
                    });
                } else {
                    that.setData({
                        myMessage: []
                    });
                }
            }
        });
    },
    //获取我的通知
    getMyNotice:function(){
        var that = this;
        var userInfo = JSON.parse(wx.getStorageSync("userInfo"));
        util.wxAjax("guestbook/msgList","post",{
            adminid: userInfo.smAdmin.id
        },function(res){
            var data = res.data;
            if (data.result == 200 || data.result == "200") {
                if (!!data.data) {
                    that.setData({
                        myNotice: data.data
                    });
                } else {
                    that.setData({
                        myNotice: []
                    });
                }
            }
        });
    }
})